export const chan = [{
		name: "	北京仓	",
		address: "	北京市顺义区北务镇民泰路16号院	"
	},
	{
		name: "	南昌仓	",
		address: "	江西省南昌市青山湖区昌东工业园谢佛路1028号供储物流园306号	"
	},
	{
		name: "	赣州仓	",
		address: "	江西省赣州市南康区赣州经济技术开发区新能源汽车科技城城西大道99号	"
	},
	{
		name: "	福州仓	",
		address: "	福建省福州市闽侯县南屿镇智慧大道1号天美实业2号楼唯捷城配"
	},
	{
		name: "	厦门仓	",
		address: "	福建省漳州台商投资区角美镇田里村恒苍183号菜鸟网络物流园区2号库	"
	},
	{
		name: "	杭州仓	",
		address: "	普冷杭州欣衡库：浙江省杭州市钱塘区10号大街36号A04普冷国际（库迪咖啡项目组）	"
	},
	{
		name: "	宁波仓	",
		address: "	浙江省宁波市奉化区恒安路777号宁波中通优鲜美库	"
	},
	{
		name: "	金华仓	",
		address: "	浙江省金华市婺城区金竹路2299号大战物流园1号库9号门	"
	},
	{
		name: "	温州仓	",
		address: "	杭州代收（普冷杭州欣衡库：浙江省杭州市钱塘区10号大街36号A04普冷国际（库迪咖啡项目组）	"
	},
	{
		name: "	合肥仓	",
		address: "	安徽省合肥市宝湾物流肥东有限公司6号库	"
	},
	{
		name: "	沈阳仓	",
		address: "	辽宁省沈阳市沈北新区蒲新路36-1号B2库	"
	},
	{
		name: "	大连仓	",
		address: "	辽宁省大连市甘井子区大连湾街道拉树渤海路新空街5号	"
	},
	{
		name: "	长春仓	",
		address: "	长春市宽城区北远达大街与宝成路交汇长春鹏达安平物流园A1-4	"
	},
	{
		name: "	哈尔滨仓	",
		address: "	哈尔滨市香坊区同江南路1号交投万纬冷链物流园	"
	},
	{
		name: "	成都仓	",
		address: "	普冷成都龙泉驿库-成都市龙泉驿区车城车城大道668号成工物流园2号门C1库（普冷龙泉冻库）（禁止放快递柜暂放点门卫）	"
	},
	{
		name: "	拉萨仓	",
		address: "	普冷拉萨库常温库：西藏自治区拉萨市柳梧新区柳梧大道高原蓝冷储9号-普冷国际	"
	},
	{
		name: "	昆明仓	",
		address: "	云南省昆明市官渡区经济技术开发区清水片区环普产业园B-1库	"
	},
	{
		name: "	重庆仓	",
		address: "	重庆市沙坪坝区龚安大道548号A4-1	"
	},
	{
		name: "	贵阳仓	",
		address: "	贵州省贵阳市修文县扎佐镇贵阳农产品物流园农投惠民生鲜经营公司配送中心	"
	},
	{
		name: "	南宁仓	",
		address: "	广西壮族自治区南宁市良庆区定旧路2号-传胜供应链南宁园区	"
	},
	{
		name: "	桂林仓	",
		address: "	广西桂林市临桂区瑞宁路11号桂林中辰电商物流交易中心1#6-10号库	"
	},
	{
		name: "	海口仓	",
		address: "	海南省海口市美兰区桂秀路罗牛山冷链物流园4号库2楼5号仓	"
	},
	{
		name: "	长沙仓	",
		address: "	湖南省长沙市芙蓉区隆园五路苏宁芙蓉物流中心乐行百川南面 C5号库	"
	},
	{
		name: "	衡阳仓	",
		address: "	衡阳市雁峰区白沙洲工业园区衡阳白沙洲物流园有限公司D区-4	"
	},
	{
		name: "	武汉仓	",
		address: "	普冷武汉光谷库-湖北省 武汉市 江夏区 泉岗街 民生电商民熙华中产业园 武汉普冷国际物流有限公司 A3库	"
	},
	{
		name: "	宜昌仓	",
		address: "	宜昌市高新区生物产业园片区土门路B2库	"
	},
	{
		name: "	广州仓	",
		address: "	广州市番禺区化龙镇龙津路1号云食城智慧产业园3栋	"
	},
	{
		name: "	深圳仓	",
		address: "	深圳市龙岗区园山街道山子下路130号怡禾仓库101室	"
	},
	{
		name: "	南京仓	",
		address: "	南京市江宁区禄口街道华商路40号普洛斯物流园A3唯捷配送	"
	},
	{
		name: "	苏州仓	",
		address: "	苏州市虎丘区青花路128号安博中国	"
	},
	{
		name: "	徐州仓	",
		address: "	江苏省徐州市贾汪区大吴街道程楼社区双楼港_徐州凯熠仓储信华国际4号库	"
	},
	{
		name: "	扬州仓	",
		address: "	泰州市高港区创新大道301	"
	},
	{
		name: "	上海仓	",
		address: "	上海市青浦区白石公路2989号雨润物流园2楼(D-2-10)	"
	},
	{
		name: "	郑州仓	",
		address: "	河南省郑州市经开区南三环与二十大街交叉口东南角宝海物流园飞洁冷链（进大门右转坡道上二层，直走300米右手边锁鲜冷链）	"
	},
	{
		name: "	济南仓	",
		address: "	济南市临港开发区临港路与新兴路交汇处北100米普洛斯物流园唯捷城配	"
	},
	{
		name: "	青岛仓	",
		address: "	山东省青岛市城阳区流亭街道瑞仁路1号平安嘉丰物流园A3库25号门	"
	},
	{
		name: "	临沂仓	",
		address: "	山东省临沂市河东区芝麻墩街道杭州路21号立晨物流院内4号库	"
	},
	{
		name: "	太原仓	",
		address: "	山西省太原市小店区宏业路8号京东亚洲一号太原萧河物流园（5号门进1号库2楼112门）	"
	},
	{
		name: "	呼和浩特仓	",
		address: "	内蒙古呼和浩特市新城区锦鑫机动车检测技术有限公司院内	"
	},
	{
		name: "	石家庄仓	",
		address: "	河北省石家庄市正定县车站西街与云长路交叉口西340米河北正定深国际综合物流港	"
	},
	{
		name: "	天津仓	",
		address: "	天津市西青区王稳庄镇普洛斯普金物流园A4库德邦供应链	"
	},
	{
		name: "	西安仓	",
		address: "	陕西省西安市灞桥区普洛斯西安贺韶物流园A1库	"
	},
	{
		name: "	兰州仓	",
		address: "	甘肃省兰州市秦川镇大夏河街280号公航旅金融仓储基地1期  	"
	},
	{
		name: "	乌鲁木齐仓	",
		address: "	新疆维吾尔自治区乌鲁木齐市头屯河区酒花路11号新疆丽生恒伟供应链管理有限公司院内2号库	"
	},
	{
		name: "	当涂中心仓	",
		address: "	安徽省马鞍山市当涂县经济开发区大成坊西路与205国道交叉口顺丰产业园二期五号库	"
	},


]

const db=uniCloud.databaseForJQL()
function generateCode(){
	const randomNum = Math.floor(Math.random() * 10000);
	// 将数字转为字符串并补零至四位
	const paddedNum = randomNum.toString().padStart(4, '0');
	// 组合成最终编码
	const code = `CK${paddedNum}`;
	return code;
}
const Amap=uniCloud.importObject('getTokens')
const formlist =[]

export async function test() {
  const res= await db.collection('warehouse').get()
    const houser=  res.data.filter(item=>!item.location)

  for (const ch of houser) {
    
    const form = {
      address: "",
      location: "",
      adcode: "",
  
    };
    const res = await getAddress(ch);
    form.address = res.address;
    form.location = res.location;
    form.adcode = res.adcode;
   const id=await db.collection('warehouse').where(
	   {_id:ch._id}
   ).update(
	   form
   )
   
  }


}

async function getAddress(add) {
  const m = { address: "", adcode: "", location: "" };
  const address = add.address.trim();
  if (!address || address.length < 6) {

    return m;
  }
  try {
    const res = await Amap.getAddressToGps(address);
    if (res.status !== '1') {

      return m;
    }
    if (!res.geocodes || res.geocodes.length === 0) {

      return m;
    }
    const geocode = res.geocodes[0];
    m.address = geocode.formatted_address || "";
    m.location = geocode.location || "";
    m.adcode = geocode.adcode || "";
  } catch (err) {
    console.log(err);
  }
  return m;
}
